/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.manchester.biology.eqhei.persistence;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mlwyatt
 */
@Entity
@Table(name = "StreamReach")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "StreamReach.findAll", query = "SELECT s FROM StreamReach s"),
    @NamedQuery(name = "StreamReach.findByUtm", query = "SELECT s FROM StreamReach s WHERE s.utm = :utm"),
    @NamedQuery(name = "StreamReach.findByAlias", query = "SELECT s FROM StreamReach s WHERE s.alias = :alias"),
    @NamedQuery(name = "StreamReach.findByStream", query = "SELECT s FROM StreamReach s WHERE s.stream = :stream")})
public class StreamReach implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "UTM")
    private String utm;
    
    
    @Size(max = 50)
    @Column(name = "alias")
    private String alias;
    
    
    @Size(max = 50)
    @Column(name = "stream")
    private String stream;
    
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "streamReach")
    private Collection<Evaluation> evaluationCollection;
    
    
    @OneToMany(mappedBy = "utm")
    private Collection<EvaluationSection> evaluationSectionCollection;

    public StreamReach() {
    }

    public StreamReach(String utm) {
        this.utm = utm;
    }

    public String getUtm() {
        return utm;
    }

    public void setUtm(String utm) {
        this.utm = utm;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getStream() {
        return stream;
    }

    public void setStream(String stream) {
        this.stream = stream;
    }

    @XmlTransient
    public Collection<Evaluation> getEvaluationCollection() {
        return evaluationCollection;
    }

    public void setEvaluationCollection(Collection<Evaluation> evaluationCollection) {
        this.evaluationCollection = evaluationCollection;
    }

    @XmlTransient
    public Collection<EvaluationSection> getEvaluationSectionCollection() {
        return evaluationSectionCollection;
    }

    public void setEvaluationSectionCollection(Collection<EvaluationSection> evaluationSectionCollection) {
        this.evaluationSectionCollection = evaluationSectionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (utm != null ? utm.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StreamReach)) {
            return false;
        }
        StreamReach other = (StreamReach) object;
        if ((this.utm == null && other.utm != null) || (this.utm != null && !this.utm.equals(other.utm))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.manchester.biology.eqhei.business.StreamReach[ utm=" + utm + " ]";
    }
    
}
